package org.springblade.modules.repair.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.tool.api.R;
import org.springblade.modules.repair.service.IMaintainElevatorStatisticsService;
import org.springblade.modules.repair.vo.statistics.ps.ComplianceStatusVO;
import org.springblade.modules.repair.vo.statistics.ps.OverviewVO;
import org.springblade.modules.repair.vo.statistics.ps.PlanLoseVO;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

/**
 * @Description 维保电梯统计
 * @Author ysq
 * @Date 2023/6/28
 **/
@RestController
@AllArgsConstructor
@RequestMapping("maintain/elevator/statistics")
@Api(value = "维保电梯统计统计", tags = "维保电梯统计接口")
public class MaintainElevatorStatisticsController extends BladeController {

	private final IMaintainElevatorStatisticsService maintainElevatorStatisticsService;

	@GetMapping("/plan/schedule/overview")
	@ApiOperationSupport(order = 1)
	@ApiOperation(value = "电梯保养排期概况")
	public R<OverviewVO> planScheduleOverview() {
		return R.data(maintainElevatorStatisticsService.planScheduleOverview());
	}

	@GetMapping("/plan/compliance/status")
	@ApiOperationSupport(order = 2)
	@ApiOperation(value = "在保年审梯保养合规情况")
	public R<ComplianceStatusVO> planComplianceStatus() {
		return R.data(maintainElevatorStatisticsService.planComplianceStatus());
	}

	@GetMapping("/plan/lose")
	@ApiOperationSupport(order = 3)
	@ApiOperation(value = "脱保电梯总览")
	public R<PlanLoseVO> planLose() {
		return R.data(maintainElevatorStatisticsService.planLose());
	}

	@GetMapping("/plan/schedule/excel")
	@ApiOperationSupport(order = 4)
	@ApiOperation(value = "电梯保养排期概况excel")
	public R<String> planScheduleExcel(@ApiParam(value = "0-有剩余排期，1-无剩余排期，默认-0") @RequestParam(required = false, defaultValue = "0") Integer type) throws IOException {
		return R.data(maintainElevatorStatisticsService.planScheduleExcel(type));
	}

	@GetMapping("/not/plan/schedule/excel")
	@ApiOperationSupport(order = 4)
	@ApiOperation(value = "从未排期电梯excel")
	public R<String> notPlanScheduleExcel() throws IOException {
		return R.data(maintainElevatorStatisticsService.notPlanScheduleExcel());
	}

	@GetMapping("/plan/compliance/status/excel")
	@ApiOperationSupport(order = 5)
	@ApiOperation(value = "在保年审梯保养合规情况excel")
	public R<String> planComplianceStatusExcel(@ApiParam(value = "年审梯保养合规状态") @RequestParam Integer type) throws IOException {
		return R.data(maintainElevatorStatisticsService.planComplianceStatusExcel(type));
	}

	@GetMapping("/plan/lose/excel")
	@ApiOperationSupport(order = 6)
	@ApiOperation(value = "脱保电梯总览excel")
	public R<String> planLoseExcel() throws IOException {
		return R.data(maintainElevatorStatisticsService.planLoseExcel());
	}
}
